using CHEnhanceEfCore.Common;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace CHEnhanceEfCore.Filter
{
    /// <summary>
    /// author: chenhao
    /// </summary>
    public class GlobalExceptionFilter : IExceptionFilter
    {
        public void OnException(ExceptionContext context)
        {
            string message = context.Exception.Message;
            var json = Result.fail(message);
            context.Result = new JsonResult(json);
        }
    }
}